package com.kang.controller;

import com.kang.vo.FriendGroupVo;
import com.kang.bean.Friend;
import com.kang.commons.Result;
import com.kang.service.FriendService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: photo_fawu
 * @description: 好友
 * @author: K.faWu
 * @create: 2021-11-09 10:53
 **/
@RestController
@RequestMapping("/friend")
@Slf4j
public class FriendController {

    @Autowired
    private FriendService friendService;

    @GetMapping
    public Result<?> getByUser(Long userId){
        log.info("获取用户的好友：{}", userId);
        List<FriendGroupVo> list= friendService.getByUserId(userId);
        return Result.success(list);
    }

    /**
     * 添加好友
     */
    @PostMapping
    public Result<?> addFriend(@RequestBody Friend friend){
        friendService.addFriend(friend);
        return Result.success();
    }
}
